//
//  FFView.m
//  EasyToTesco
//
//  Created by mc on 16/3/21.
//  Copyright © 2016年 Jack. All rights reserved.
//

#import "FFView.h"

@interface FFView(){
    
}

@end


@implementation FFView
-(instancetype)initWithFrame:(CGRect)frame {
    self  = [super initWithFrame:frame];
    if (self) {
        CGFloat weith = CGRectGetWidth(self.frame);
        CGFloat heigh = CGRectGetHeight(self.frame);
        _firstview = [[UIView alloc] initWithFrame:CGRectMake(10, (heigh-10)/2, 10, 10)];
        _firstview.layer.borderWidth = 1;
        _firstview.layer.borderColor = [UIColor grayColor].CGColor;
        _firstview.layer.cornerRadius = CGRectGetHeight(_firstview.frame)/2;
        _firstview.layer.masksToBounds = YES;
        _firstview.backgroundColor = [UIColor greenColor];
        [self addSubview:_firstview];
        
        
        _firstlabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_firstview.frame)+5, (heigh-15)/2, weith-30, 15)];
        _firstlabel.text = @"余额支付";
        _firstlabel.font = [UIFont systemFontOfSize:12];
        _firstlabel.textAlignment = NSTextAlignmentLeft;
        [self addSubview:_firstlabel];
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.frame = self.frame;
    
        [button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:button];
    }
    return self;
}

- (void)buttonClick:(UIButton *)button {
    self.firstview.backgroundColor = [UIColor greenColor];
    [self.delegate FFBtnClick:button];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
